package com.jinhongone.pattern.behavior.command;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jinho
 * @className Waiter
 * @description 服务员（调用者）
 * @date 2025/3/31 9:30
 */
public class Waiter {
    //服务员可以接收多个命令
    private List<Command> commands;

    public Waiter() {
        commands = new ArrayList<>();
    }

    //接收命令
    public void setCommand(Command command) {
        this.commands.add(command);
    }

    //发起命令
    public void orderUp() {
        System.out.println("服务员发起命令....");
        for (Command command : commands) {
            if (command != null) {
                command.execute();
            }
        }
    }


}
